<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="breadcrumbs">
        <h:form>
            <a href="index.xhtml">Website Admin</a><div class="breadcrumb_divider"></div>
            <h:commandLink action="#{examsController.prepareList()}" value="Exams" immediate="true"/>
            <div class="breadcrumb_divider"></div><a class="current">Create</a>
        </h:form>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form" id="form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorClass="errorStyle" infoClass="infoStyle" layout="table" >
                    </h:messages>
                </h:panelGroup>
                <article class="module width_full">
			<header><h3>Create Exam</h3></header>
                        <div class="module_content">
                            <h:panelGrid columns="4" width="100%">
                    <h:outputLabel value="#{bundle.CreateExamsLabel_dateCreate}" for="dateCreate" />
                    <p:calendar id="dateCreate" value="#{examsController.selected.dateCreate}" title="#{bundle.CreateExamsTitle_dateCreate}" pattern="MM/dd/yyyy HH:mm">
                    </p:calendar>
                    <h:outputLabel value="#{bundle.CreateExamsLabel_dateStart}" for="dateStart" />
                    <p:calendar id="dateStart" value="#{examsController.selected.dateStart}" title="#{bundle.CreateExamsTitle_dateStart}" pattern="MM/dd/yyyy HH:mm">
                        
                    </p:calendar>
                    <h:outputLabel value="#{bundle.CreateExamsLabel_dateEnd}" for="dateEnd" />
                    <p:calendar id="dateEnd" value="#{examsController.selected.dateEnd}" title="#{bundle.CreateExamsTitle_dateEnd}" pattern="MM/dd/yyyy HH:mm">
                    </p:calendar>
                    <h:outputLabel value="#{bundle.CreateExamsLabel_dateReCounting}" for="dateReCounting" />
                    <p:calendar id="dateReCounting" value="#{examsController.selected.dateReCounting}" title="#{bundle.CreateExamsTitle_dateReCounting}" pattern="MM/dd/yyyy HH:mm">
                    </p:calendar>
                    <h:outputLabel value="Assign to:" for="AssignTo" />
                    <p:selectOneMenu id="AssignTo" value="#{examsController.selected.assignFac}" effect="fold" style="width:160px" >
                        <f:selectItems value="#{examsController.allUserses}" var="user" itemLabel="#{user}" itemValue="#{user}"/>
                    </p:selectOneMenu>
                    <h:outputLabel value="#{bundle.CreateExamsLabel_subjectId}" for="subjectId" />
                    <p:selectOneMenu id="subjectId" value="#{examsController.selected.subjectId}" effect="fold" style="width:160px" >
                        <f:selectItems value="#{examsController.allSubject}"/>
                        <p:ajax update="AssignTo" event="change"/>
                    </p:selectOneMenu>
                </h:panelGrid>
                <br />
                <div align="right">
                    <h:commandButton action="#{examsController.create}" value="#{bundle.CreateExamsSaveLink}" />
                </div>
                <br />
                </div>
                </article>
                <article class="module width_quarter" style="width: 400px;height: 300px;" >
                    <header><h3>Search Student</h3></header>
                    <h:panelGrid columns="2" width="100%">
                        <h:outputLabel value="Role No.:" for="rollNo" />
                        <p:inputText id="rollNo" value="#{examsController.rollNo}" title="Roll No." >
                            <p:ajax event="blur" update="rollNo" />  
                        </p:inputText>
                        
                        <h:outputLabel value="Student Name:" for="stuName" />
                        <p:inputText id="stuName" value="#{examsController.studentName}" title="Student Name" >
                            <p:ajax event="blur" update="stuName" />
                        </p:inputText>
                        
                        <h:outputLabel value="Class:" for="Class" />
                        <p:selectOneMenu id="class" value="#{examsController.classe}" effect="fold" style="width:160px" 
                                         >
                            <f:selectItem itemLabel="Select class" itemValue="" /> 
                            <f:selectItems value="#{examsController.allClasses}"/>
                            <p:ajax update="studentSearch"  
                                    listener="#{examsController.changeStudentList}" event="change"/>
                        </p:selectOneMenu>
                        
                        <h:outputLabel value=""/>
                        <h:commandButton value="Search" action="#{examsController.changeStudentList}" />
                    </h:panelGrid>
                    <div class=""></div>
                </article>
                <article class="module width_quarter" style="width: 550px;height: 300px;" >
                    <header><h3>Result student list</h3></header>
                    <div class="">
                        <h:panelGrid columns="1" width="100%">
                        <p:dataTable id="studentSearch" var="item" value="#{examsController.listStudent}" paginator="true" rows="10" style="width: 90%;text-align: center;margin: 0 auto;height: 220px;" 
                                     selection="#{examsController.listStudentSelected}" rowKey="#{item.enRoll}" scrollHeight="220">  
                            
                            <p:column selectionMode="multiple" style="width:2%" />
                            <p:column headerText="Roll No." sortBy="#{item.enRoll}">  
                                #{item.enRoll}  
                            </p:column>
                            
                            <p:column headerText="Student name" sortBy="#{item.stuName}">  
                                #{item.stuName}  
                            </p:column>
                        </p:dataTable>
                        <h:commandButton value="Add" actionListener="#{examsController.addStudent}"/> 
                        </h:panelGrid>
                    </div>
                </article>
                <div class="clear"></div>
                <br />
                <article class="module width_full">
			<header><h3>Student of exam</h3></header>
                        <div class="module_content">
                            <p:dataTable id="studentList" var="item" value="#{examsController.listStudentCreate}" paginator="true" rows="10"
                                    >  
                            <p:column headerText="Roll No." sortBy="#{item.enRoll}">  
                                #{item.enRoll}  
                            </p:column>
                            
                            <p:column headerText="Student name" sortBy="#{item.stuName}">  
                                #{item.stuName}  
                            </p:column>
                            
                                <p:column style="width: 10px;">
                                    <f:facet name="header">
                                        <h:outputText value="&nbsp;"/>
                                    </f:facet>
                                    <h:commandButton title="Delete" value="delete" actionListener="#{examsController.removeStudent(item)}">
                                        <p:ajax update="studentList"/>
                                    </h:commandButton>
                                </p:column>
                                
                        </p:dataTable>
                        </div>
                </article>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
